package edu.hawaii.myisern.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the MyResearcher record class.
 * 
 * @author Randy Cox
 * 
 */
public class TestMyResearcher {

  /**
   * Test constructor, make sure fields are initialized.
   */
  @Test
  public void testMyResearcher() {
    MyResearcher researcher = new MyResearcher();

    // Check init.
    assertNotNull("Check non-null ID.", researcher.getId());
    assertNotNull("Check non-null name.", researcher.getName());
    assertNotNull("Check non-null email.", researcher.getEmail());
    assertNotNull("Check non-null organization.", researcher.getOrganization());
    assertNotNull("Check non-null pictureLink.", researcher.getPictureLink());
    assertNotNull("Check non-null bio.", researcher.getBio());

    // Set up test strings.
    String id = ("FIRST_LAST");
    String name = "First Last ";
    String email = "Email";
    String org = "Org";
    String pict = "Pict";
    String bio = "Bio";

    // Set up record vars.
    researcher.setName(name);
    researcher.setEmail(email);
    researcher.setOrganization(org);
    researcher.setPictureLink(pict);
    researcher.setBio(bio);

    // Check vars.
    assertEquals("Check ID.", id, researcher.getId());
    assertEquals("Check name.", name, researcher.getName());
    assertEquals("Check email.", email, researcher.getEmail());
    assertEquals("Check organization.", org, researcher.getOrganization());
    assertEquals("Check pictureLink.", pict, researcher.getPictureLink());
    assertEquals("Check bio.", bio, researcher.getBio());

    // Check toString().
    String comma = ", ";
    String expected = id + comma + name + comma + email + comma + org + comma + pict + comma + bio;
    assertEquals("Check toString.", expected, researcher.toString());

    // Check validate.
    assertTrue("Check validate.", researcher.validate());
    researcher.setEmail("");
    assertFalse("Check bad validate.", researcher.validate());
  }

}
